In puppeteer's declaration file types.d.ts, I came across the following type definition:
export declare type EvaluateFunc<T extends unknown[]>
= (...params: InnerParams<T>) => Awaitable<unknown>;
export declare type InnerParams<T extends unknown[]> = {
[K in keyof T]: FlattenHandle<T[K]>;
};
My question is in regards to <T extends unknown[]> and the operator precedence for typeof and [] .. is T extending unknown? Or is it extending unknown[], and, if it's the latter, then is the keyof operator able to be used on type Array? If so, does typescript take this to mean 'any numeric property of an array'? (aka, array item).
Assuming it's the former, and T is extending unknown, then how does the array shorthand [] operator affect the typeof operator? Just for context, here is the definition for FlattenHandle:
export declare type FlattenHandle<T> = T extends HandleOr<infer U> ? U : never;
Sub-question: export declare -- I've taken a break from TS for half a year and now that I'm back, I'm seeing these more and more. Is it a recent addition? What are we trying to say here? That, the type exists but was not exported in the source? One of the affects of this export declare is that my IDE (PHPStorm) thinks that the class ElementHandle exists, and even appears in console.log, but, if you Console.log(ElementHandle) you will get undefined:
export declare class ElementHandle<ElementType extends Node = Element> extends JSHandle<ElementType> {
#private;
// ...
Thank you for your help.